function count_same_elements(collection) {
  //在这里写入代码
  let arr = [] ;
  let obj = {} ;
  for(let item of collection){
      if(item.length != 1){
          if(!obj[item[0]]){
              obj[item[0]] = {} ;
              obj[item[0]].key = item[0] ;
              obj[item[0]].count = parseInt(item.replace(/[^0-9]/ig,''));
          }else{
              obj[item[0]].count +=  parseInt(item.replace(/[^0-9]/ig,''));
          }
      }else{
          if(!obj[item]){
              obj[item] = {} ;
              obj[item].key = item ;
              obj[item].count = 1;
          }else{
              obj[item].count ++ ;
          }
      }
  }
  for(let value in obj){
      arr.push(obj[value]) ;
  }
  return arr ;
}

module.exports = count_same_elements;
